package com.westar.base.exceptions;

/**
 * 登录异常信息
 */
public class AffariBusinessException extends Exception {

    //参数校验异常
    public static Integer VALIDATE_EXCEPTION_CODE = 11;
    //需要重新上传的
    public static Integer HANDLE_TOKEN_CODE = 12;
    //需要配置初试数据才能继续操作的
    public static Integer HANDLE_INITDATA_CODE = 13;
    //账号密码认证失败
    public static Integer AUTHER_DENY_CODE = 14;

    /**
     * 异常信息
     */
    protected String msg;
    /**
     * 具体异常码
     */
    protected int code;

    public AffariBusinessException(int code, String msgFormat, Object... args) {
        super(String.format(msgFormat, args));
        this.code = code;
        this.msg = String.format(msgFormat, args);
    }

    public AffariBusinessException() {
        super();
    }

    public String getMsg() {
        return msg;
    }

    public int getCode() {
        return code;
    }

    /**
     * 实例化异常
     *
     * @param msgFormat
     * @param args
     * @return
     */
    public AffariBusinessException newInstance(String msgFormat, Object... args) {
        return new AffariBusinessException(this.code, msgFormat, args);
    }

    public AffariBusinessException(String message, Throwable cause) {
        super(message, cause);
    }

    public AffariBusinessException(Throwable cause) {
        super(cause);
    }

    public AffariBusinessException(String message) {
        super(message);
    }
}
